import 'package:flutter/widgets.dart';

class DialogBottomAnim extends StatefulWidget {
  final Animation<double> animation;
  final Widget child;

  const DialogBottomAnim(
      {Key? key, required this.animation, required this.child})
      : super(key: key);

  @override
  _DialogBottomAnimState createState() => _DialogBottomAnimState();
}

class _DialogBottomAnimState extends State<DialogBottomAnim> {
  late Tween<Offset> tweenOffset;

  late Animation<double> animation;

  @override
  void initState() {
    tweenOffset = Tween<Offset>(
      begin: const Offset(0.0, 1),
      end: Offset.zero,
    );
    animation =
        CurvedAnimation(parent: widget.animation, curve: Curves.decelerate);
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return AnimatedBuilder(
      child: widget.child,
      animation: widget.animation,
      builder: (BuildContext context, Widget? child) {
        return FractionalTranslation(
          translation: tweenOffset.evaluate(animation),
          child:child,
        );
      },
    );
  }
}
